/*
 * $Author: isan.wong@gmail.com $
 * $Date $
 * $Rev: 13 $
 * $URL: http://capitalbio-smd.googlecode.com/svn/src/com/capitalbio/smd/gui/StdGeneComboBox.java $
 */

package com.capitalbio.smd.gui;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.capitalbio.smd.base.StdGene;
import com.capitalbio.smd.base.StdGeneFactory;
import com.capitalbio.smd.base.Util;

public class StdGeneComboBox extends JComboBox{
	private static final long serialVersionUID = 1L;
	protected static Log log = LogFactory.getLog(StdGeneComboBox.class);
	
	public StdGeneComboBox() {
		StdGeneComboBoxModel symbolComboBoxModel = new StdGeneComboBoxModel();
		setModel(symbolComboBoxModel);
	}
}

class StdGeneComboBoxModel extends DefaultComboBoxModel implements ComboBoxModel {
	private static final long serialVersionUID = 1L;
	protected static Log log = LogFactory.getLog(StdGeneComboBoxModel.class);
	
	public StdGeneComboBoxModel() {
		for (String stdGeneName : StdGeneFactory.getNames()) {
			StdGene stdGene = StdGeneFactory.getGene(stdGeneName);
			//log.debug("StdGene: " + stdGene.getName());
			
			addElement(stdGene);
			if (Util.getProperties().getProperty("smd.alignment.gene.default").equals(stdGeneName)) {
				setSelectedItem(stdGene);
			}
		}
	}
}
